<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // // 展开运算符 ...
        // // 数组的展开
        // let arr = [1, 2, 4];
        // let arr1 = [6, 7, 8];
        // let newArr = [...arr, ...arr1];
        // console.log(newArr);

        // let arr2 = [1, 2,[3, 4, 5, [6, 7]]];
        // let newArr1 = arr2.flat(2);
        // console.log(newArr1);

        // // 处理不定参数, rest剩余参数
        // function fun(a, ...arg) {
        //     console.log(arg);
        // 1.通过 Array.from 来把伪数组转成数组 
        //    var arr =  Array.from(arguments);
        //    console.log(arr);
        // 2.通过展开运算符 来转换
        // var arr = [...arguments];
        // console.log(arr);
        // }
        // fun(1, 2, 3, 4)

        // // 对象的展开
        // let obj1 = {name: '张三'};
        // let obj2 = {hobby: '篮球'};
        // let obj3 = {...obj1, ...obj2}
        // console.log(obj3);

        // 字符串的展开
        let str = 'hsjhkjshhl';
        let res = [...str];
        console.log(res);   //['h', 's', 'j', 'h', 'k', 'j', 's', 'h', 'h', 'l']

        // 字符串的split方法
        let str1 = 'hjhjkjklkldhjl';
        let res1 = str1.split('');
        let res2 = str1.split('h');
        console.log(res1);//['h', 'j', 'h', 'j', 'k', 'j', 'k', 'l', 'k', 'l', 'd', 'h', 'j', 'l']
        console.log(res2);//['', 'j', 'jkjklkld', 'jl']

        let str2 = 'my name is 王俊凯';
        let res3 = str2.split(' ');//
        let res4 = str2.split();//
        console.log(res3);//['my', 'name', 'is', '王俊凯']
        console.log(res4);//['my', 'name', 'is', '王俊凯']

        



        


        

        // 可以把伪数组转成数组；
    </script>
</body>
</html>